﻿@model Vizzio.Models.Socio

@{
    ViewBag.Title = "Editar Socio";
}

<h2>Editar Socio</h2>


@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "formularioPersona" }))
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>Socio</h4>
        <p><font color="blue" face="Verdana" size="2">Todos los campos con * son obligatorios</font></p>
        <hr />
        @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.SocioID)

        <div class="control-group form-group">
            @*@Html.LabelFor(model => model.CI, "* CI", new { @class = "control-label col-md-2" })*@
            <label class="control-label col-md-2"><strong>* CI</strong></label>
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.CI, new { @class = "form-control", required = "", data_validation_required_message = "Campo requerido", maxlength = "10", data_validation_maxlength_message = "Muy largo: Ingrese menos de 15 digitos", minlength = "6", data_validation_minlength_message = "Muy corto: Ingrese al menos 6 digitos", data_validation_number_message = "Debe ingresar solo numeros", data_validation_callback_callback = "validar_ci_socio_repetido" })
                <p class="help-block">Campo requerido. De 6 a 10 Digitos Numericos</p>
                @Html.ValidationMessageFor(model => model.CI)
            </div>
        </div>

        <div class="control-group form-group">
            @*@Html.LabelFor(model => model.Nombre, "* Nombre", new { @class = "control-label col-md-2" })*@
            <label class="control-label col-md-2"><strong>* Nombre</strong></label>
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.Nombre, new { @class = "form-control", required = "", data_validation_required_message = "Campo requerido", maxlength = "20", data_validation_maxlength_message = "Muy largo: Ingrese 20 o menos caracteres", minlength = "1", data_validation_minlength_message = "Muy corto: Ingrese al menos 1 caracter", data_validation_regex_regex = "([A-ZñÑáéíóa-z]+[ ]*)+([A-ZñÑa-z])*", data_validation_regex_message = "Solo caracteres Alfabeticos. No puede empezar con espacio" })
                <p class="help-block">1 a 20 Caracteres Albeticos</p>
            </div>
        </div>

        <div class="control-group form-group">
            @*@Html.LabelFor(model => model.Apellidos, "* Apellidos", new { @class = "control-label col-md-2" })*@
            <label class="control-label col-md-2"><strong>* Apellidos</strong></label>
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.Apellidos, new { @class = "form-control", required = "", data_validation_required_message = "Campo requerido", maxlength = "30", data_validation_maxlength_message = "Muy largo: Ingrese 30 o menos caracteres", minlength = "1", data_validation_minlength_message = "Muy corto: Ingrese al menos 1 caracter", data_validation_regex_regex = "([A-ZñÑáéíóa-z]+[ ]*)+([A-ZñÑa-z])*", data_validation_regex_message = "Solo caracteres Alfabeticos. No puede empezar con espacio" })
                <p class="help-block">1 a 30 Caracteres Albeticos</p>
            </div>
        </div>

        <div class="control-group form-group">
            @*@Html.LabelFor(model => model.Telefono,"* Telefono", new { @class = "control-label col-md-2" })*@
            <label class="control-label col-md-2"><strong>* Telefono</strong></label>
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.Telefono, new { @class = "form-control", required = "", data_validation_required_message = "Campo requerido", maxlength = "10", data_validation_maxlength_message = "Muy largo: Ingrese menos de 10 digitos", minlength = "7", data_validation_minlength_message = "Muy corto: Ingrese al menos 7 digitos", data_validation_number_message = "Debe ingresar solo numeros" })
                <p class="help-block">Campo requerido. De 7 a 10 Digitos Numericos</p>
                @Html.ValidationMessageFor(model => model.Telefono)
            </div>
        </div>

        <div class="control-group form-group">
            @*@Html.LabelFor(model => model.Celular,"* Celular", new { @class = "control-label col-md-2" })*@
            <label class="control-label col-md-2"><strong>* Celular</strong></label>
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.Celular, new { @class = "form-control", required = "", data_validation_required_message = "Campo requerido", maxlength = "11", data_validation_maxlength_message = "Muy largo: Ingrese menos de 11 digitos", minlength = "8", data_validation_minlength_message = "Muy corto: Ingrese al menos 8 digitos", data_validation_number_message = "Debe ingresar solo numeros" })
                <p class="help-block">Campo requerido. De 8 a 11 Digitos Numericos</p>
                @Html.ValidationMessageFor(model => model.Celular)
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Modifiar" class="btn btn-warning " />
            </div>
        </div>

    </div>
}

<div>
    @Html.ActionLink("Cancelar", "Index", null, new { @class = "btn btn-success" })
</div>

@section Scripts {
    <script>
        $(function () { $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); });
    </script>

<script>
    var SocioID = @Model.SocioID
    function validar_ci_socio_repetido($el, value, validar_ci) {
        var obj = { CI: value, SocioID: SocioID };//Datos enviados
        $.ajax({
            type: "POST",
            url: "http://localhost:6490/Service/WebServiceGetProductos.asmx/ModificarCiSocioDisponible",
            dataType: "json",
            data: JSON.stringify(obj),
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                validar_ci({
                    value: value,
                    valid: JSON.parse(data.d),
                    message: "Duplicidad: El CI ingresado ya fue registrado!!"
                });
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus + " Error: " + XMLHttpRequest.responseText);
            }
        });
    }
</script>

    @Scripts.Render("~/bundles/jqueryval")
}
